package com.chilly.tx;

import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * REQUIRED
 * Created by Chilly Cui on 2020/9/25.
 */
public class TxPropagation1RequiredDemo {
    void test1() {
        new A().aMethod();
    }
}

class A {
    //@Transactional(propagation = Propagation.REQUIRED)
    public void aMethod() {
        //do something
        B b = new B();
        b.bMethod();
        System.out.println("a");
    }
}

class B {
    @Transactional(propagation = Propagation.REQUIRED)
    public void bMethod() {
        System.out.println("b");
        //do something
    }
}